#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    void sortColors(vector<int>& nums) {
        int left = 0, cur = 0, right = nums.size() - 1;
        while (cur <= right)
        {
            if (nums[cur] == 0) swap(nums[left++], nums[cur++]);
            else if (nums[cur] == 2) swap(nums[right--], nums[cur]);
            else cur++;
        }
    }
};